package timing.ukulele.form.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import timing.ukulele.common.ResponseResult;
import timing.ukulele.form.persistent.EntityFieldConfig;
import timing.ukulele.form.service.EntityFieldConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/entityConfigField")
@Api(tags = "实体字段配置")
@Slf4j
public class EntityFieldConfigController {

    final EntityFieldConfigService service;

    public EntityFieldConfigController(EntityFieldConfigService service) {
        this.service = service;
    }


    /**
     * 查询当前模板包含的所有字段
     *
     * @return
     */
    @GetMapping("/page")
    public ResponseResult<IPage<EntityFieldConfig>> page(@ApiParam(value = "模板id", example = "1") @RequestParam(value = "entityConfigId") Long entityConfigId,
                                                         @ApiParam(value = "描述", example = "dojfjdof") @RequestParam(value = "description", required = false) String description,
                                                         @ApiParam(value = "字段", example = "jfojdof") @RequestParam(value = "field", required = false) String field,
                                                         @ApiParam(value = "当前页码", required = true, example = "1") @RequestParam Integer pageNum,
                                                         @ApiParam(value = "每页大小", required = true, example = "10") @RequestParam Integer pageSize) {
        return service.page(entityConfigId, description, field, pageNum, pageSize);
    }
}
